package cn.shengchao.examstar.ai.acl.adapters;

import cn.shengchao.examstar.ai.acl.ports.ICourseWatchTimeService;
import cn.shengchao.examstar.rpc.me.api.CourseWatchTimeService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * 课程观看时长服务实现
 * 作为防腐层适配器，直接调用ME模块的服务
 */
@Service
@Slf4j
public class CourseWatchTimeServiceImpl implements ICourseWatchTimeService {

    @Autowired
    private CourseWatchTimeService courseWatchTimeService;

    @Override
    public Long getTotalWatchLengthBySpecificationType(Long userId, Long specificationTypeId) {
        try {
            // 直接调用ME模块的服务
            return courseWatchTimeService.getTotalWatchLengthBySpecificationType(userId, specificationTypeId);
        } catch (Exception e) {
            log.error("调用ME模块获取课程观看时长失败: userId={}, specificationTypeId={}", userId, specificationTypeId, e);
            return 0L;
        }
    }
} 